package com.styles.codingstyle.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
 * @Description: swagger2配置
 * @Param: 
 * @Return: 
 * @Author: 陈建
 * @date: 2018/6/6 9:25
*/
@EnableSwagger2
@Configuration
public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        //配置扫描路径
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.styles.codingstyle.controller")).paths(PathSelectors.any()).build();
    }

    //Swagger2基础属性配置
    private ApiInfo apiInfo() {
        ApiInfoBuilder builder = new ApiInfoBuilder();
        //标题
        builder.title("CodingStyle");
        //描述
        builder.description("APIs");
        //服务地址
        builder.termsOfServiceUrl("");
        //作者
        builder.contact("Name");
        //版本
        builder.version("1.0");
        return builder.build();
    }
}
